package com.feihao.zhou.demo01_Thread;

import java.util.*;
import java.util.stream.Stream;

public class StreamDemo01 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("rrr");
        list.add("ddd");
        list.add("aaa");
        list.add("sss");

        //转化stream流并打印：
        list.stream().forEach(s -> System.out.println(s));

        //map：
        Map<String, String> map = new HashMap<>();
        map.put("33", "dd");
        map.put("44", "ee");
        map.put("55", "rr");
        map.put("66", "tt");
        map.keySet().stream().forEach(s -> System.out.println(s + "=" + map.get(s)));

        System.out.println("=================entry===================");
        map.entrySet().stream().forEach(s-> System.out.println(s));


        //数组：
        int[] arr = {1, 2, 3, 5, 9, 3, 2};
        Arrays.stream(arr).forEach(s-> System.out.println(s));

        System.out.println("========");

        Stream<Integer> integerStream = Stream.of(1, 2, 3, 5, 9, 3, 2);
        integerStream.forEach(s-> System.out.println(s));
        System.out.println("----------------------------");
        List<String> list1 = List.of("1", "55", "44");

        ArrayList<String> arrayList = new ArrayList<>(list1);
        for (String s : arrayList) {
            System.out.println(s);
        }
    }
}
